/*
LANG:C++
TASK:ttwo
ID:luongho3
*/
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("ttwo.in");
ofstream fout("ttwo.out");
#define GSIZE 11
#define NORTH 0
#define EAST 1
#define SOUTH 2
#define WEST 3
#define UNVISITED -1
char map[GSIZE][GSIZE];
int mcow[GSIZE][GSIZE], mjohn[GSIZE][GSIZE];
int rjohn,cjohn,djohn,rcow,ccow,dcow;
void read_data() {
     int i,j;
     for (i=1;i<GSIZE;++i) {
         fin >> (map[i] + 1);
         for (j=1;j<GSIZE;++j) {
             mcow[i][j] = UNVISITED;
             mjohn[i][j] = UNVISITED;
             if (map[i][j] == 'C') {
                rcow = i;
                ccow = j;
                mcow[i][j] = NORTH;
             }
             else if (map[i][j] == 'F') {
                  rjohn = i;
                  cjohn = j;
                  mjohn[i][j] = NORTH;
             }
         }
     }
     djohn = dcow = NORTH;
}
int next_dir(int dir) {
    return (dir+1)%4;
}
bool go(int &row, int &col, int &dir) {
     if (dir == NORTH) {
          if (row==1 || map[row-1][col]=='*') {
             dir = next_dir(dir);
             return false;
          }     
          else {
               row = row-1;
               return true;
          }
     }
     else if (dir == EAST) {
          if (col==10 || map[row][col+1]=='*') {
             dir = next_dir(dir);
             return false;
          }
          else {
               col = col+1;
               return true;
          }
     }
     else if (dir == SOUTH) {
          if (row==10 || map[row+1][col]=='*') {
             dir = next_dir(dir);
             return false;
          }
          else {
               row = row+1;
               return true;
          }
     }
     else {
          if (col==1 || map[row][col-1]=='*') {
             dir = next_dir(dir);
             return false;
          }
          else {
               col = col-1;
               return true;
          }
     }
}
int counter = 0;
bool jrepeat,crepeat;
int main() {
    read_data();
    jrepeat = crepeat = false;
    while (1) {
          if (rjohn==rcow && cjohn==ccow) {
             break;
          }
          else {
               bool gjohn = go(rjohn,cjohn,djohn);
               bool gcow = go(rcow,ccow,dcow);
               if (gjohn==false) {
                  //no change in john's position
                  if (mjohn[rjohn][cjohn] == djohn) {
                     jrepeat = true;
                  }
               }
               else {
                    if (mjohn[rjohn][cjohn] == UNVISITED) {
                       mjohn[rjohn][cjohn] = djohn;
                    }
                    else if (mjohn[rjohn][cjohn] == djohn) {
                         jrepeat = true;
                    }
               }
               if (gcow==false) {
                  //no change in cow's position
                  if (mcow[rcow][ccow] == dcow) {
                     crepeat = true;
                  }
               }
               else {
                    if (mcow[rcow][ccow] == UNVISITED) {
                       mcow[rcow][ccow] = dcow; 
                    }
                    else if (mcow[rcow][ccow] == dcow) {
                         crepeat = true;
                    }
               }
               //if (jrepeat==true && crepeat==true) { !!this is not true as F and C repeat indepedently, not simultaneously
               if (counter>=160000) {
                  counter = -1;
                  break;
               }
               else {
                    counter = counter + 1;
               }
          }
    }
    if (counter==-1) {
       fout <<"0\n";
    }
    else {
         fout <<counter<<"\n";
    }
    return 0;
}
